﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Debugging
{
    public partial class frmDebugging : Form
    {
        public frmDebugging()
        {
            InitializeComponent();
            init();
        }

        string[] title = new string[] {"Miss", "Mr", "Mrs", "Ms"};
        string[] city = new string[] { "Auckland", "Blenheim", "Christchurch", "Dunedin" };
        string firstName, middleInitial, lastName, stAddress, assembledAddress;

        private void init()
        {
            cboTitle.Items.Clear();
            foreach (string item in title)
            {
                cboTitle.Items.Add(item);
            }

            cboCity.Items.Clear();
            foreach (string item in city)
            {
                cboCity.Items.Add(item);
            }
        }

        private void getInput()
        {
            firstName = txtFirstName.Text;
            middleInitial = txtMiddleInitial.Text;
            lastName = txtLastName.Text;
            stAddress = txtStAddress.Text;
        }

        private void assemble()
        {
            assembledAddress = cboTitle.SelectedItem + " " + firstName.Substring(0, 1).ToUpper() + " " + middleInitial.Substring(0, 1).ToUpper() + " " + lastName + "\r\n" + stAddress + "\r\n" + cboCity.SelectedItem;
            txtOutput.Text = assembledAddress;
        }

        private void btnAssemble_Click(object sender, EventArgs e)
        {
            getInput();
            assemble();

        }

    }
}
